package com.event.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.event.pojo.PostComment;
import com.event.mapper.PostCommentMapper;
import com.event.service.PostCommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 帖子一级评论 服务实现类
 * </p>
 *
 * @author 孤雏
 * @since 2021-08-09
 */
@Service
public class PostCommentServiceImpl extends ServiceImpl<PostCommentMapper, PostComment> implements PostCommentService {
    @Autowired
    PostCommentMapper postCommentMapper;
    @Override
    @Cacheable(value = "PostComment")
    public List<PostComment> selectPostComment(PostComment postComment) {
        return postCommentMapper.selectPostComment(postComment);
    }

    @Override
    public List<PostComment> selectPostCommentByLike(PostComment postComment) {
        return postCommentMapper.selectPostCommentByLike(postComment);
    }

    @Override
    @CacheEvict(value = "PostComment", allEntries=true)
    @Transactional
    public boolean deleteComment(Long commentId) {
        return removeById(commentId);
    }

    @Override
    @CacheEvict(value = "PostComment", allEntries=true)
    @Transactional
    public int insertComment(PostComment postComment) {
        return postCommentMapper.insert(postComment);
    }
}
